from Mysql_cl import *
class ICBC:
    __account = 0
    __password = ""
    __money = 0

    def __init__(self,account,password,money):
        self.__account = account
        self.__password = password
        self.__money = money
    def Kai(self):
        sql = "insert into icbc value (%s,%s,%s,NOW())"
        param = [self.__account,self.__password,self.__money]
        insert(sql,param)
    def Cha(self):
        sql = "select * from icbc where account = %s and password = %s"
        param = [self.__account,self.__password]
        return  select(sql,param,mode="one")
    def Cun(self):
        sql = "select money from icbc where account = %s and password = %s"
        param = [self.__account,self.__password]
        b = select(sql,param,mode="one")[0]+self.__money
        sql1 = "update icbc set money = %s where account = %s"
        param1 = [b,self.__account]
        updata(sql1,param1)
    def Zhuan(self):
        sql = "select money from icbc where account = %s and password = %s"
        param = [self.__account, self.__password]
        b = select(sql, param, mode="one")[0]-self.__money
        sql1 = "update icbc set money = %s where account = %s"
        param1 = [b, self.__account]
        updata(sql1, param1)
    def Shou(self):
        sql = "select money from icbc where account = %s"
        param = self.__account
        b = select(sql, param, mode="one")[0]+self.__money
        sql1 = "update icbc set money = %s where account = %s"
        param1 = [b, self.__account]
        updata(sql1, param1)

